#include "AnimPlayer/Actions/MarqueeAction.h"

void FMarqueeAction::OnInit()
{
	FActionBase::OnInit();

	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(0);
		Layer->DoMarquee(AnimTarget,Direction,ElementId, Value);
	}
}

void FMarqueeAction::OnBegin()
{
	FActionBase::OnBegin();

	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(0);
		Layer->DoMarquee(AnimTarget,Direction,ElementId, Value);
	}
}

void FMarqueeAction::OnTick(float DeltaTime)
{
	FActionBase::OnTick(DeltaTime);
	
	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(Timer);
		Layer->DoMarquee(AnimTarget,Direction,ElementId, Value);
	}
}

void FMarqueeAction::OnEnd()
{
	FActionBase::OnEnd();

	if (Layer.IsValid() && CurveWrapper.IsValid())
	{
		const float Value = CurveWrapper->GetValueByTime(Duration);
		Layer->DoMarquee(AnimTarget,Direction,ElementId, Value);
	}
}
